<template>
    <div>
        
        <div class="div">
            <el-input
            placeholder="请输入客户名称"
            v-model="form.name"
            clearable>
            </el-input>

            <br/><br/>
             <el-input
            placeholder="请输入公司地址"
            v-model="form.address"
            clearable>
            </el-input>

            <br/><br/>
             <el-input
            placeholder="请输入联系人名称"
            v-model="form.contacts_name"
            clearable>
            </el-input>

            <br/><br/>
             <el-input
            placeholder="请输入联系人电话"
            v-model="form.contacts_phone"
            clearable>
            </el-input>
        </div>

        <div class="div2">
            <el-row>
                <el-button type="success" @click="post_client" size='medium'>提交</el-button>
            </el-row>
        </div>

    </div>
</template>



<script>
import { client_post} from '../../api/api'
export default {
    inject:['reload'],
    data(){
        return{
            form:{
                name:'',
                address:'',
                contacts_phone:'',
                contacts_name:'',
                company_id:'',
            },  
        }
    },
    mounted() {
        //获取所属公司
        this.form.company_id = localStorage.getItem('com_id')
    },
    methods: {
        //添加客户
        post_client(){
            client_post(this.form).then(res=>{
                if(res.code==200){
                    this.$message(res.message)
                    this.reload()
                }else{
                    thsi.$message('公司名-地址已经存在')
                }
            })
        }
    },
}
</script>



<style >
.div{
    width: 300px;
    padding: 100px 0px 0px 600px;
}
.div2{
    padding: 20px 0px 0px 700px;
}
</style>